package cn.jja8.config.tool.work.obj.parameterized;

import java.util.LinkedHashMap;
import java.util.Map;

public class FieldAsMap implements ParameterizedKeep<Map> {


    @Override
    public Map in(Object con, TypeKeep[] typeKeeps) throws Throwable {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        ((Map)con).forEach((o, o2) -> linkedHashMap.put(typeKeeps[0].in(o),typeKeeps[1].in(o2)));
        return linkedHashMap;
    }

    @Override
    public Object out(Map map, TypeKeep[] typeKeeps) throws Throwable {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        map.forEach((o, o2) -> linkedHashMap.put(typeKeeps[0].out(o),typeKeeps[1].out(o2)));
        return linkedHashMap;
    }
}
